<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>
<title></title>
  <style type="text/css">
    <!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
  </style>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head><body>


<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = -->
<!-- =   Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard  markus@jave.de   = -->
<!-- =     Further information: http://www.java2html.de     = -->
<div align="left" class="java">
<table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff">
   <tr>
  <!-- start source code -->
   <td nowrap="nowrap" valign="top" align="left">
    <code>
<font color="#3f7f5f">//传入请求参数</font><br />
<font color="#000000">String&nbsp;storagepoolName&nbsp;=&nbsp;request.getParameter</font><font color="#000000">(</font><font color="#2a00ff">&#34;storagepoolName&#34;</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#000000">String&nbsp;parentId&nbsp;=&nbsp;request.getParameter</font><font color="#000000">(</font><font color="#2a00ff">&#34;parentId&#34;</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#000000">String&nbsp;id&nbsp;=&nbsp;request.getParameter</font><font color="#000000">(</font><font color="#2a00ff">&#34;id&#34;</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#7f0055"><b>long&nbsp;</b></font><font color="#000000">userConsumedCapacityThreshold&nbsp;=&nbsp;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">Long.parseLong</font><font color="#000000">(</font><font color="#000000">request.getParameter</font><font color="#000000">(</font><font color="#2a00ff">&#34;userConsumedCapacityThreshold&#34;</font><font color="#000000">))</font><font color="#000000">;</font><br />
<font color="#000000">String&nbsp;tier&nbsp;=&nbsp;request.getParameter</font><font color="#000000">(</font><font color="#2a00ff">&#34;tier&#34;</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#7f0055"><b>int&nbsp;</b></font><font color="#000000">capacity&nbsp;=&nbsp;Integer.parseInt</font><font color="#000000">(</font><font color="#000000">request.getParameter</font><font color="#000000">(</font><font color="#2a00ff">&#34;capacity&#34;</font><font color="#000000">))</font><font color="#000000">;</font><br />
<font color="#3f7f5f">//&nbsp;创建存储池对象，设置id、parentId、userConsumedCapacityThreshold、名称等属性</font><br />
<font color="#000000">StoragePoolMO&nbsp;storagePoolMO&nbsp;=&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">StoragePoolMO</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">!</font><font color="#2a00ff">&#34;&#34;</font><font color="#000000">.equals</font><font color="#000000">(</font><font color="#000000">id</font><font color="#000000">))</font><br />
<font color="#000000">{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">storagePoolMO.setId</font><font color="#000000">(</font><font color="#000000">id</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#000000">}</font><br />
<font color="#000000">storagePoolMO.setParentId</font><font color="#000000">(</font><font color="#000000">parentId</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#000000">storagePoolMO.setUserConsumedCapacityThreshold</font><font color="#000000">(</font><font color="#000000">userConsumedCapacityThreshold</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#000000">storagePoolMO.setName</font><font color="#000000">(</font><font color="#000000">storagepoolName</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#2a00ff">&#34;tier0&#34;</font><font color="#000000">.equals</font><font color="#000000">(</font><font color="#000000">tier</font><font color="#000000">))</font><br />
<font color="#000000">{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">storagePoolMO.setTier0Capacity</font><font color="#000000">(</font><font color="#000000">capacity&nbsp;*&nbsp;</font><font color="#990000">1024&nbsp;</font><font color="#000000">*&nbsp;</font><font color="#990000">1024&nbsp;</font><font color="#000000">*&nbsp;</font><font color="#990000">1024L</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">storagePoolMO.setTier0RaidLv</font><font color="#000000">(</font><font color="#000000">RaidLevelE.RAID_LEVEL_RAID5</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#000000">}</font><br />
<font color="#7f0055"><b>else&nbsp;if&nbsp;</b></font><font color="#000000">(</font><font color="#2a00ff">&#34;tier1&#34;</font><font color="#000000">.equals</font><font color="#000000">(</font><font color="#000000">tier</font><font color="#000000">))</font><br />
<font color="#000000">{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">storagePoolMO.setTier1Capacity</font><font color="#000000">(</font><font color="#000000">capacity&nbsp;*&nbsp;</font><font color="#990000">1024&nbsp;</font><font color="#000000">*&nbsp;</font><font color="#990000">1024&nbsp;</font><font color="#000000">*&nbsp;</font><font color="#990000">1024L</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">storagePoolMO.setTier1RaidLv</font><font color="#000000">(</font><font color="#000000">RaidLevelE.RAID_LEVEL_RAID5</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#000000">}</font><br />
<font color="#7f0055"><b>else</b></font><br />
<font color="#000000">{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">storagePoolMO.setTier2Capacity</font><font color="#000000">(</font><font color="#000000">capacity&nbsp;*&nbsp;</font><font color="#990000">1024&nbsp;</font><font color="#000000">*&nbsp;</font><font color="#990000">1024&nbsp;</font><font color="#000000">*&nbsp;</font><font color="#990000">1024L</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">storagePoolMO.setTier2RaidLv</font><font color="#000000">(</font><font color="#000000">RaidLevelE.RAID_LEVEL_RAID5</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#000000">}</font><br />
<font color="#7f0055"><b>try</b></font><br />
<font color="#000000">{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">StoragePoolHandler&nbsp;storagePoolHandler&nbsp;=&nbsp;</font><font color="#000000">(</font><font color="#000000">StoragePoolHandler</font><font color="#000000">)&nbsp;</font><font color="#000000">manager</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">.getHandler</font><font color="#000000">(</font><font color="#000000">HandlerConstant.STORAGEPOOL_HANDLER</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//&nbsp;调用create方法创建存储池</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">storagePoolHandler.create</font><font color="#000000">(</font><font color="#000000">storagePoolMO</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#000000">}</font><br />
<font color="#7f0055"><b>catch&nbsp;</b></font><font color="#000000">(</font><font color="#000000">ApiException&nbsp;e</font><font color="#000000">)</font><br />
<font color="#000000">{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;new&nbsp;</b></font><font color="#000000">Gson</font><font color="#000000">()</font><font color="#000000">.toJson</font><font color="#000000">(</font><font color="#000000">e.getMessage</font><font color="#000000">())</font><font color="#000000">;</font><br />
<font color="#000000">}</font><br />
<font color="#ffffff"></font><br />
<font color="#7f0055"><b>return&nbsp;new&nbsp;</b></font><font color="#000000">Gson</font><font color="#000000">()</font><font color="#000000">.toJson</font><font color="#000000">(</font><font color="#2a00ff">&#34;success&#34;</font><font color="#000000">)</font><font color="#000000">;</font></code>
    
   </td>
  <!-- end source code -->
   </tr>
</table>
</div>
<!-- =       END of automatically generated HTML code       = -->
<!-- ======================================================== -->


</body></html>